package com.trump.baiduim.service.impl;

import com.trump.baiduim.dao.FriendshipDao;

import com.trump.baiduim.dao.UserDao;
import com.trump.baiduim.model.Friendship;
import com.trump.baiduim.model.User;
import com.trump.baiduim.service.FriendshipService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author xujb
 * @date 2020/11/24 18:07
 */
@Service
public class FriendshipServiceImpl implements FriendshipService {
    @Autowired
    private FriendshipDao friendshipDao;
    
    @Autowired
    private UserDao userDao;

    @Override
    public void addFriend(String friendshipSender, String friendshipReceiver) {

        Friendship friendship = new Friendship();

        friendship.setFriendshipSender(friendshipSender);
        friendship.setFriendshipReceiver(friendshipReceiver);

        friendshipDao.insertSelective(friendship);
    }

    @Override
    public void deleteFriend(Long friendshipId) {
        friendshipDao.deleteByPrimaryKey(friendshipId);
    }

    /**
     *wjj
     */
    //通过用户账号获取用户好友列表
    @Override
    public List<User> findFriendList(String userAccount) {
        return friendshipDao.findFriendList(userAccount);
    }

    @Override
    public List<User> fuzzySearch(String departmentName, String userName) {
        return userDao.fuzzySearch(departmentName,userName);
    }
}
